/*
 * Created on 15/07/2010
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.stefanini.pe.bbva.iivs.in.listeners;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

/**
 * @author tgagliuffi
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class SpringInit implements ServletContextListener {

    @SuppressWarnings("unused")
	private static final Logger logger = Logger.getLogger(SpringInit.class);
    private static WebApplicationContext springContext;
    
    public void contextInitialized(ServletContextEvent event) {
        springContext = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());
    }
    
    public void contextDestroyed(ServletContextEvent event) {
        springContext = null;
    }
    
    public static ApplicationContext getApplicationContext() {
        return springContext;
    }

}
